import request from '@/utils/request'

export const addressApi = {
    // 获取用户的配送地址列表
    listDeliveryAddressByUserId(params) {
        return request.post('DeliveryAddressController/listDeliveryAddressByUserId', {
            userName: params.userName
        })
    },

    // 保存配送地址
    saveDeliveryAddress(params) {
        return request.post('DeliveryAddressController/saveDeliveryAddress', {
            userName: params.userName,
            contactName: params.contactName,
            contactSex: String(params.contactSex),
            contactTel: params.contactTel,
            address: params.address
        })
    },

    // 获取配送地址详情
    getDeliveryAddressById(params) {
        return request.post('DeliveryAddressController/getDeliveryAddressById', {
            daId: params.daId,
            userName: params.userName
        })
    },

    // 修改配送地址
    updateDeliveryAddress(params) {
        return request.post('DeliveryAddressController/updateDeliveryAddress', {
            daId: String(params.daId),
            userName: params.userName,
            contactName: params.contactName,
            contactSex: String(params.contactSex),
            contactTel: params.contactTel,
            address: params.address
        })
    },

    // 删除配送地址
    removeDeliveryAddress(params) {
        return request.post('DeliveryAddressController/removeDeliveryAddress', {
            daId: String(params.daId),
            userName: params.userName
        })
    }
}

export default addressApi 